import { NOT_MOUNTED, MOUNTED, UNLOADING } from "../application/app.helpers.js"

export function toUnmountPromise(app) {
   return Promise.resolve().then(() => {
      if (app.status !== MOUNTED) {
         // 应用没有挂载
         return app;
      }

      app.status = UNLOADING; // 设置应用状态为卸载中
      return app.unmount(app.customProps).then(() => {
         app.status = NOT_MOUNTED; // 卸载完毕
         return app;
      })
   })
}